/*
 * @lc app=leetcode.cn id=2164 lang=typescript
 *
 * [2164] 对奇偶下标分别排序
 */

// @lc code=start
function sortEvenOdd(nums: number[]): number[] {
    for (let i = 0; i < nums.length; i += 2) {
        for (let j = i + 2; j < nums.length; j += 2) {
            if (nums[i] >= nums[j]) {
                [nums[i], nums[j]] = [nums[j], nums[i]];
            }
        }
    }
    for (let i = 1; i < nums.length; i += 2) {
        for (let j = i + 2; j < nums.length; j += 2) {
            if (nums[i] <= nums[j]) {
                [nums[i], nums[j]] = [nums[j], nums[i]];
            }
        }
    }

    return nums;
}
// @lc code=end
